package com.ssy.lingxi.platform.manage.controller.content;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.entity.content.ContentImage;
import com.ssy.lingxi.platform.manage.model.request.common.CommonIdRequest;
import com.ssy.lingxi.platform.manage.model.request.common.CommonStatusRequest;
import com.ssy.lingxi.platform.manage.model.request.content.ContentImagePageRequest;
import com.ssy.lingxi.platform.manage.model.request.content.ContentImageRequest;
import com.ssy.lingxi.platform.manage.model.response.StartAndGuideResponse;
import com.ssy.lingxi.platform.manage.service.content.IContentImageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @menu 内容管理 - 图片管理
 * @author fhj
 * @version 2.0.0
 * @date 2020/9/17
 */
@Api(tags = "内容管理 - 图片管理")
@RestController
@RequestMapping("/manage/contentImage")
public class ContentImageController extends BaseController {

    @Resource
    private IContentImageService contentImageService;

    @ApiOperation(value = "列表")
    @GetMapping("/page")
    public Wrapper<PageData<ContentImage>> page(ContentImagePageRequest request) {
        return contentImageService.page(request);
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/get")
    public Wrapper<ContentImage> get(@Validated CommonIdRequest request) {
        return contentImageService.get(request);
    }

    @ApiOperation(value = "新增")
    @PostMapping(value = "/add")
    public Wrapper<Void> add(@RequestBody @Validated({ContentImageRequest.Add.class}) ContentImageRequest request) {
        return contentImageService.add(request, getSysUser());
    }

    @ApiOperation(value = "修改")
    @PostMapping(value = "/update")
    public Wrapper<Void> update(@RequestBody @Validated({ContentImageRequest.Update.class}) ContentImageRequest request) {
        return contentImageService.update(request, getSysUser());
    }

    @ApiOperation(value = "停用/启用")
    @PostMapping(value = "/updateStatus")
    public Wrapper<Void> updateStatus(@RequestBody @Validated ({CommonStatusRequest.Enable.class}) CommonStatusRequest request) {
        return contentImageService.updateStatus(request, getSysUser());
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public Wrapper<Void> delete(@RequestBody @Validated CommonIdRequest request) {
        return contentImageService.delete(request, getSysUser());
    }

    @ApiOperation(value = "根据使用场景和所在位置获取所有")
    @GetMapping(value = "/findAllByUseSceneAndPosition")
    public Wrapper<List<ContentImage>> findAllByUseSceneAndPosition(Integer useScene, Integer position) {
        return contentImageService.findAllByUseSceneAndPosition(useScene, position);
    }

    @ApiOperation(value = "启动页、引导页")
    @GetMapping(value = "/startAndGuide")
    public Wrapper<StartAndGuideResponse> startAndGuide() {
        return contentImageService.startAndGuide();
    }
}
